#include <TrainerLib.h>
#include <iostream>
#include "resource.h"

#ifndef DEBUG
// Disable command prompt window
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

inline std::string i2str(int i)
{
	char buffer[15];
	_itoa_s(i, buffer, 15, 10);
	return std::string(buffer);;
}

int main(int argc, char* argv[])
{
	TLib::STrainer app("Minesweeper", "Minesweeper Trainer", 200, 200, IDI_APPICON);
	app.setAboutInfo("Minesweeper Trainer +2\nglass660@gmail.com");

	/*
	Un-Patched:
	Poke 100371A 89 3D 9C 57 00 01 // MOV command
	Poke 1003830 FF 05 9C 57 00 01
	Poke 1002FF5 FF 05 9C 57 00 01

	Patched:
	Poke 100371A 90 90 90 90 90 90
	Poke 1003830 90 90 90 90 90 90
	Poke 1002FF5 90 90 90 90 90 90
	*/
	
	TLib::SCheat* makeTimeAlwaysZero = new TLib::SCheat("Make Time Always Zero", &app);
	makeTimeAlwaysZero->addNopPatch(0x1003830, 6);
	makeTimeAlwaysZero->addNopPatch(0x1002FF5, 6);
	
	/*
	Un-Patched:
	Address   Hex dump          Command                           
	01001E70  8B88 10500001     MOV ECX,DWORD PTR DS:[EAX+1005010]


	Patched:
	Address   Hex dump          Command 
	01001E70  B9 01 00 00 00       MOV ECX,1
	01001E75  90                NOP
	*/

	BYTE newMem[] = {0xB9,0x01,0x00,0x00,0x00, 0x90};
	TLib::SCheat* makeNumMinesAlwaysOne = new TLib::SCheat("Make Number of Mines Always 1", &app);
	makeNumMinesAlwaysOne->addSMemPatch(0x01001E70, newMem, 6); 

#ifdef DEBUG
	// Add some cheats to test scroll bars
	for (int i = 0; i < 20; i++)
	{
		app.addCheat(new TLib::SCheat(i2str(i), &app));
	}
#endif




	app.addCheat(makeTimeAlwaysZero);
	app.addCheat(makeNumMinesAlwaysOne);
	return app.Run();
}